// pages/kydzz/answer/answer.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    value1: '',
    value2: '',
    value3: '',
    value4: '',
    value5: '',
    value6: '',
    value7: '',
    value8: '',
    value9: '',
    value10: '',
    value11: '',
    value12: '',
    value13: '',
    value14: '',
    value15: '',
    value16: ''
  },
  radioChange1(e) {
    const _ = this;
    console.log(e.detail.value)
    _.setData({
      value1: e.detail.value
    })
  },
  radioChange2(e) {
    const _ = this;
    console.log(e.detail.value)
    const value = e.detail.value;
    _.setData({
      value2: e.detail.value
    })
    if (value == '一战') {
      _.setData({
        yizhan: 1,
        erzhan: !1
      })
    } else {
      _.setData({
        yizhan: !1,
        erzhan: 1
      })
    }
  },
  radioChange3(e) {
    const _ = this;
    console.log(e.detail.value)
    _.setData({
      value3: e.detail.value
    })
  },
  radioChange4(e) {
    const _ = this;
    console.log(e.detail.value)
    _.setData({
      value4: e.detail.value
    })
  },
  radioChange5(e) {
    const _ = this;
    console.log(e.detail.value)
    _.setData({
      value5: e.detail.value
    })
  },
  radioChange6(e) {
    const _ = this;
    console.log(e.detail.value)
    _.setData({
      value6: e.detail.value
    })
  },
  radioChange7(e) {
    const _ = this;
    console.log(e.detail.value)
    _.setData({
      value7: e.detail.value.toString()
    })
  },
  radioChange8(e) {
    const _ = this;
    console.log(e.detail.value)
    _.setData({
      value8: e.detail.value.toString()
    })
  },
  radioChange9(e) {
    const _ = this;
    console.log(e.detail.value)
    _.setData({
      value9: e.detail.value
    })
  },
  radioChange10(e) {
    const _ = this;
    console.log(e.detail.value)
    _.setData({
      value10: e.detail.value
    })
  },
  radioChange11(e) {
    const _ = this;
    console.log(e.detail.value)
    _.setData({
      value11: e.detail.value.toString()
    })
  },
  radioChange12(e) {
    const _ = this;
    console.log(e.detail.value)
    _.setData({
      value12: e.detail.value
    })
  },
  radioChange13(e) {
    const _ = this;
    console.log(e.detail.value)
    _.setData({
      value13: e.detail.value
    })
  },
  radioChange14(e) {
    const _ = this;
    console.log(e.detail.value)
    _.setData({
      value14: e.detail.value
    })
  },
  radioChange15(e) {
    const _ = this;
    console.log(e.detail.value)
    _.setData({
      value15: e.detail.value
    })
  },
  radioChange16(e) {
    const _ = this;
    console.log(e.detail.value)
    _.setData({
      value16: e.detail.value
    })
  },
  submit(e) {
    const _ = this;
    const phone = wx.getStorageSync('kydzzphone')
    if(_.data.value1&&_.data.value2&&_.data.value3&&_.data.value4&&_.data.value5&&_.data.value6&&_.data.value7&&_.data.value8&&_.data.value9&&_.data.value10&&_.data.value11&&_.data.value12){
      wx.request({ //发送请求
        url: "https://zg99.offcn.com/index/biaodan/updateuser/?actid=48402&callback=?",
        data: {
          phone: phone,
          value1: _.data.value1,
          value2: _.data.value2,
          value3: _.data.value3,
          value4: _.data.value4,
          value5: _.data.value5,
          value6: _.data.value6,
          value7: _.data.value7,
          value8: _.data.value8,
          value9: _.data.value9,
          value10: _.data.value10,
          value11: _.data.value11,
          value12: _.data.value12,
          value13: _.data.value13,
          value14: _.data.value14,
          value15: _.data.value15,
          value16: _.data.value16,
        }, //接收参数
        success(res) { //返回
          var jsonStr = res.data;
          jsonStr = jsonStr.replace("(", "");
          jsonStr = jsonStr.replace(")", "");
          if (typeof jsonStr != 'object') {
            jsonStr = jsonStr.replace(/\ufeff/g, ""); //字符串转化JSON对象
            var theJson = JSON.parse(jsonStr);
          };
          console.log(theJson)
          wx.setStorageSync('isWj', 1)
          wx.navigateTo({
            url: '../zl/zl?area=' + _.data.area + '&agent=' + _.data.agent + '&page=' + _.data.page
          })
        }
      })
    } else{
      wx.showToast({
        title: '请完整填写必选项',
        icon:'none'
      })
    }
    
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    var _ = this;
    console.log(options)
    _.setData({
      area: options.area,
      agent: options.agent,
    })
    if (options.page) {
      _.setData({
        page: options.page
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享 
   */
  onShareAppMessage() {
    var _ = this;
    return {
      title: '考研大作战调查问卷',
      path: 'pages/kydzz/index/index?area=' + _.data.area + '&agent=' + _.data.agent + '&page=' + _.data.page
    }
  },
  //用户点击右上角分享朋友圈
  onShareTimeline: function () {
    var _ = this;
    return {
      title: '考研大作战调查问卷',
      path: 'pages/kydzz/index/index?area=' + _.data.area + '&agent=' + _.data.agent + '&page=' + _.data.page
    }
  }
})